home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Hyper
/
C-Cl
/
clipToICON XCMD.cpt
/
clipToICON XCMD Folder
/
clipToICON XCMD
/
cards.xml
< prev
next >
Wrap
Text File
|
1991-10-03
|
12KB
|
225 lines
card_2847.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE card PUBLIC "-//Apple, Inc.//DTD card V 2.0//EN" "" >
<card>
<id>2847</id>
<filler1>0</filler1>
<bitmap>BMAP_2249.pbm</bitmap>
<cantDelete> <false /> </cantDelete>
<showPict> <true /> </showPict>
<dontSearch> <false /> </dontSearch>
<owner>2726</owner>
<link rel="stylesheet" type="text/css" href="stylesheet_3106.css" />
<part>
<id>1</id>
<type>field</type>
<visible> <true /> </visible>
<dontWrap> <false /> </dontWrap>
<dontSearch> <false /> </dontSearch>
<sharedText> <false /> </sharedText>
<fixedLineHeight> <false /> </fixedLineHeight>
<autoTab> <false /> </autoTab>
<lockText> <false /> </lockText>
<rect>
<left>19</left>
<top>304</top>
<right>81</right>
<bottom>332</bottom>
</rect>
<style>transparent</style>
<autoSelect> <false /> </autoSelect>
<showLines> <false /> </showLines>
<wideMargins> <false /> </wideMargins>
<multipleLines> <false /> </multipleLines>
<reservedFamily> 0 </reservedFamily>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>right</textAlign>
<font>Palatino</font>
<textSize>10</textSize>
<textStyle>plain</textStyle>
<textHeight>13</textHeight>
<name></name>
<script></script>
</part>
<part>
<id>4</id>
<type>button</type>
<visible> <false /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>129</left>
<top>287</top>
<right>277</right>
<bottom>339</bottom>
</rect>
<style>roundrect</style>
<showName> <true /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>8105</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Bulb</name>
<script></script>
</part>
<part>
<id>6</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>89</left>
<top>301</top>
<right>123</right>
<bottom>302</bottom>
</rect>
<style>rectangle</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <false /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>topBorder</name>
<script></script>
</part>
<part>
<id>7</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>90</left>
<top>334</top>
<right>123</right>
<bottom>335</bottom>
</rect>
<style>rectangle</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <false /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>bottomBorder</name>
<script></script>
</part>
<part>
<id>8</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>89</left>
<top>302</top>
<right>90</right>
<bottom>335</bottom>
</rect>
<style>rectangle</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <false /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>leftBorder</name>
<script></script>
</part>
<part>
<id>9</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>122</left>
<top>301</top>
<right>123</right>
<bottom>334</bottom>
</rect>
<style>rectangle</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <false /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>rightBorder</name>
<script></script>
</part>
<content>
<layer>background</layer>
<id>4</id>
<text>clipToICON XCMD</text>
</content>
<content>
<layer>background</layer>
<id>5</id>
<text><span class="style2">lipToICON ©1991 Brett Sher</span><span class="style1"></span><span class="style2">Syntax</span><span class="style1">: clipToICON <iconName></span><span class="style2">Functionality</span><span class="style1">: clipToICON scales a PICT on the clipboard to ICON size and updates the named icon, creating it if it does not already exist in the stack. ICON names of longer than 24 characters are not accepted.</span><span class="style2">Demonstration</span><span class="style1">: To test the XCMD now, use HyperCard’s paint tools to design an icon in the designated area below. Then click the Example button. Your art will be transformed into an ICON, and a button will appear displaying your new ICON.</span><span class="style2">Credits</span><span class="style1">: Thanks to Tony Beruman for jumpstarting me into the wacky world of HyperCard externals. This XCMD was developed using CompileIt! (written by Tom Pittman and distributed by Heizer Software). I recommend CompileIt! as an inexpensive way to explore the Mac Toolbox. I have included the source code (click the show source button).</span><span class="style2">Warning:</span><span class="style1"> I make no warrantee as to the fitness of this XCMD. In fact I'd be surprised if there wasn’t some way of breaking it. After all, its my first attempt at writing an XCMD. Use it at your peril. Send bug reports and feature requests to the address below.</span><span class="style2">License:</span><span class="style1"> You are welcome to use this XCMD in your own noncommercial stacks, and to study the source code. You may freely distribute this stack to others in its original form with all copyright notices intact.However, if you plan to </span><span class="style2">resell</span><span class="style1"> this XCMD as part of a commercial product, you must first obtain my written permission.Direct your correspondence to: Brett Sher 808 Gale Drive Campbell, CA 95008</span></text>
</content>
<content>
<layer>card</layer>
<id>1</id>
<text>Draw your ICON here</text>
</content>
<content>
<layer>background</layer>
<id>14</id>
<text>-- clipToIcon 1.0, © 1991 Brett Sher, Campbell, CA, All Rights Reserved-- XCMD clipToIcon sets the bit image of the ICON resource named by the parameter <iconName> to-- the image of a PICT on the clipboard. If the PICT is not exactly 32 x 32 bits, it is scaled to fit.-- If there is not already an ICON named <iconName>, one will be added to the current stack.-- <iconName> is not allowed to be empty or exceed 24 characters.global iconRect:Record [8] -- 4 longIntsglobal pictHndl:Pointer -- handle to PICT on clipboardglobal iconHndl:Pointer -- handle to ICON resourceglobal iconDataHndl:Pointer -- handle to new ICON imageglobal graphportPtr:Pointer -- pointer to an offscreen graphportglobal oldPortPtr:Pointer -- pointer to old grafporton clipToIcon iconName if iconName is "?" then return info() if iconName is "!" then return version() if iconName is "" then return "ERROR: <iconName> was empty" if length (iconName) > 24 then return "ERROR: <iconName> was longer than 24 characters" put "" into errorMsg setRect iconRect,0,0,32,32 put newHandle(1) into pictHndl -- create a minimum size handle put getScrap(pictHndl, "PICT", pictOffset) into thePictLength -- get pictHandle from clipboard if thePictLength < 0 then put "ERROR: No PICT found on clipboard" into errorMsg else GetPort oldPortPtr -- save old grafport pointer put NewPtr(112) into graphportPtr -- It may only need 108 but a litte more shouldn't hurt OpenPort graphportPtr put iconRect into graphportPtr@.portRect put iconRect into graphportPtr@.portBits.bounds put 4 into graphportPtr@.portBits.rowbytes put newHandle(128) into iconDataHndl -- allocate space for our ICON graphic hLock iconDataHndl put iconDataHndl@ into graphportPtr@.portBits.baseAddr -- redirect quickDraw to our ICON data SetPort graphportPtr DrawPicture pictHndl, iconRect put Get1NamedResource("ICON",iconName) into iconHndl -- try to get existing ICON of same name put resError() into resErrNum if iconHndl <> 0 then -- We already have an ICON of this name BlockMove iconDataHndl@, iconHndl@,128 -- poke new bit image into our old icon else -- we need to create a new ICON repeat with i = 1 to 100 put UniqueID("ICON") into iconID if iconID> 127 then exit repeat -- guarantee no conflict with system resources end repeat if i > 99 then put "ERROR: Couldn't Generate unique id for new ICON" into ErrorMsg else AddResource iconDataHndl, "ICON", iconID, iconName -- iconDataHndl assigns our new bit image put resError() into resErrNum put Get1Resource("ICON",iconID) into iconHndl end if end if -- iconHandle now points to our ICON with an updated image if resErrNum = 0 and ErrorMsg = "" then SetResAttrs iconHndl,resChanged + resPurgeable WriteResource iconHndl put resError() into resErrNum if resErrNum <> 0 then put ResErrMsg(resErrNum) into ErrorMsg ReleaseResource iconHndl else put ResErrMsg(resErrNum) into ErrorMsg end if end if hUnlock iconDataHndl ClosePort graphportPtr DisposPtr graphportPtr SetPort oldPortPtr -- restore quickdraw to hypercard's grafPort DisposHandle iconDataHndl DisposHandle pictHndl return ErrorMsgend clipToIconfunction version return "clipToIcon 1.0, © 1991 Brett Sher, Campbell, CA, All Rights Reserved" & return &¬ "Last revised: Saturday 10/1/91"end versionfunction info return "Applies PICT on clipboard to an ICON. Syntax: clipToIcon <iconName>" & return &¬ "A new ICON is created, if the named ICON does not already exist."end infofunction ResErrMsg x if x = -192 then return "Resource not found" else if x = -193 then return "Resource file not found" else if x = -194 then return "AddResource failed" else if x = -195 then return "RmveResource failed" else if x = -196 then return "Operation prohibited by resource attribute" else if x = -199 then return "Error reading resource map" else if x = -34 then return "Disk Full" else return "Unknown resource error" && xend ResErrMsg</text>
</content>
<name></name>
<script>on closeCardhide btn 1end closeCard</script>
</card>